// OGoMojo
// Whitemice.MOGI.ZOGI.Cache
// License: LGPL
// Copyright: Whitemice Consulting, 2006
// Author(s): Adam Tauno Williams (awilliam@whitemice.org)
using System;
using System.Collections;

namespace Whitemice.MOGI.ZOGI
{
	public class Cache
	{
		Hashtable	hash;
		public Cache()
		{
			hash = new Hashtable();
		}
		
		public bool Contains(string id)
		{
			return hash.ContainsKey(id);
		}
		
		public IMOGIObject Get(string id)
		{
			if (Contains(id))
				return (IMOGIObject)((CacheEntry)hash[id]).Object;
			return null;
		}
		
		public void Put(IMOGIObject o)
		{
			if (Contains(MOGI.Id(o.Name)))
			{
				Replace(o);
			} else
				{
					hash.Add(MOGI.Id(o.Name), new CacheEntry(o));
				}
		}
		
		public void Replace(IMOGIObject o)
		{
		}
	}
}